<!--
 * @Author: your name
 * @Date: 2022-03-08 09:46:24
 * @LastEditTime: 2022-03-23 20:35:50
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue_xiaoqi\src\components\Added.vue
-->
<template>
  <div>
    <!-- <button @click="added">新增数据</button> -->
    <div class="a1">
      <form>
          姓名:
        <input type="text" v-model="Add.AddName" /><br><br>

        评分：
        <select v-model="A">
        <option>⭐</option> 
         <option>⭐⭐</option>  
          <option>⭐⭐⭐</option>     
        </select>
        <br><br>
        状态：
        <select v-model="B">
            <option>draft</option>
            <option>published</option>
        </select><br><br>

        标题：
        <input type="text" v-model="Add.AddTitle" /><br><br>

        <button @click.prevent="reset">重置</button>&nbsp;&nbsp;&nbsp;
        <button @click.prevent="append">添加</button>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  name: "VueAdded",

  data() {
    return {
        A:'⭐',
        B:"draft",
             Add: {
                 AddId:'2',
        AddName: "",
        AddEvaluate: "",
        AddState: "",
        AddTitle: "",
        AddDone: false,
      },
    };
  },
  methods: {
    // 添加
    append() {
   const EE= this.Add.AddId++ +""
   if(this.Add.AddName==""){
        alert('姓名不能为空')
      }else{
          const Add1 = {
        id:EE,
          date:Date(),
        name: this.Add.AddName,
        evaluate: this.A,
        state: this.B,
        title: this.Add.AddTitle,
        done: this.Add.AddDone,
        edit:false
      };
       this.$bus.$emit('Add1',Add1)
      }
    
      
     
    },
    // 重置
    reset() {
        this.A='⭐',
       this.B="draft",
      this.Add.AddName = "";
      this.Add.AddPassword = "";
      this.Add.AddBirthday = "";
      this.Add.AddTitle = "";
    },
  },

};
</script>

<style>

</style>